package cn.tedu.cool.controller;

import cn.tedu.cool.entity.User;
import cn.tedu.cool.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

@RestController
public class UserController {
    @Autowired(required = false)
    UserMapper userMapper;
    @RequestMapping("/cur")
    public User currentUser(HttpSession session){
        //把登录成功时保存的用户对象取出 返回给客户端
        return (User) session.getAttribute("user");
    }
    @RequestMapping("/lo")
    public void logout(HttpSession session){
        //把登录成功时保存的用户对象删除
        session.removeAttribute("user");
    }
@RequestMapping("/user/update")
    public void update(String password){
        userMapper.update(password);
}
}
